use std::fmt;
use std::fmt::{Show, Formatter};
+use std::hash;
use serialize::{Decodable, Decoder, Encodable, Encoder};
use url::Url;
}
}
-#[deriving(Encodable, Decodable, Clone, Eq, Hash)]
+#[deriving(Encodable, Decodable, Clone, Eq)]
pub struct SourceId {
pub kind: SourceKind,
pub location: Location,
}
}
+impl<S: hash::Writer> hash::Hash<S> for SourceId {
+ fn hash(&self, into: &mut S) {
+ match *self {
+ SourceId {
+ kind: ref kind @ GitKind(..),
+ location: Remote(ref url)
+ } => {
+ kind.hash(into);
+ git::canonicalize_url(url.to_string().as_slice()).hash(into);
+ }
+ _ => {
+ self.kind.hash(into);
+ self.location.hash(into);
+ }
+ }
+ }
+}
+
impl SourceId {
pub fn new(kind: SourceKind, location: Location) -> SourceId {
SourceId { kind: kind, location: location }